<?php
class Model_Code {
	function getCode($length = 32, $mode = 0) {
		switch ($mode) {
			case '1' :
				$str = '1234567890';
				break;
			case '2' :
				$str = 'abcdefghijklmnopqrstuvwxyz';
				break;
			case '3' :
				$str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
				break;
			case '4' :
				$str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
				break;
			case '5' :
				$str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
				break;
			case '6' :
				$str = 'abcdefghijklmnopqrstuvwxyz1234567890';
				break;
			default :
				$str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890';
				break;
		}
		$randString = '';
		$len = strlen ( $str ) - 1;
		for($i = 0; $i < $length; $i ++) {
			$num = mt_rand ( 0, $len );
			$randString .= $str [$num];
		}
		return $randString;
	}
}
?>